package com.user.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.user.utils.*;
import com.user.bean.Maogai;

/*持久层接口，封装了对maogai表的增删改查方法功能*/
public interface MaogaiMapper {

//	定义表名
	public static final String table="maogai";

//  查询maogai表中的所有数据
	@Select("select * from "+DBUtils.perfix+table+DBUtils.sufix+"")
	List<Maogai> selectByExample(Maogai maogai);
	
//  根据主键id查询maogai表中对应的数据
	@Select("select * from "+DBUtils.perfix+table+DBUtils.sufix+" where "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id}")
	Maogai selectByPrimaryKey(Integer id);
	
//  向maogai表中的添加一条数据
	@Insert("insert into "+DBUtils.perfix+table+DBUtils.sufix+" values(#{id},#{topic},#{topic_ans},#{answer},#{grad},#{multiple})")
	int insertSelective(Maogai maogai);

//  根据主键id更新maogai表中对应的数据
	@Update("update "+DBUtils.perfix+table+DBUtils.sufix+" set "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id},"+DBUtils.perfix+"topic"+DBUtils.sufix+"=#{topic},"+DBUtils.perfix+"topic_ans"+DBUtils.sufix+"=#{topic_ans},"+DBUtils.perfix+"answer"+DBUtils.sufix+"=#{answer},"+DBUtils.perfix+"grad"+DBUtils.sufix+"=#{grad},"+DBUtils.perfix+"multiple"+DBUtils.sufix+"=#{multiple} where "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id}")
	int updateByPrimaryKey(Maogai maogai);
	
//  根据主键id删除maogai表中对应的数据
	@Delete("delete from "+DBUtils.perfix+table+DBUtils.sufix+" where "+DBUtils.perfix+"id"+DBUtils.sufix+"=#{id}")
	int deleteByPrimaryKey(Integer id);
}